package com.four.homepage.todo;

import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TodoDao {
    //查
    @Select("SELECT * FROM todo ")
    List<TodoEntity> selectTodosByNumber();

    //删
    @Delete("delete from todo where id=#{id}")
    public int deleteTodosById(Integer id);

    //增
    @Insert("INSERT INTO todo (todo) " +
            "VALUES ( #{todo})")
    int insertTodo(TodoEntity todoEntity);

    //限制个数
    @Select("SELECT COUNT(*) FROM todo ")
    int countTodosByNumber();

    // 检查待办事项内容是否存在
    @Select("SELECT COUNT(*) FROM todo WHERE todo = #{todo}")
    int countTodoByTodo(@Param("todo") String todo);
}
